home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / microcrn / issue_46.arc / 86WRLD46.ARC / 86WORLD.11 < prev    next >
Encoding:
Text File  |  1988-05-11  |  1.4 KB  |  44 lines

  1. /* 86WORLD Figure 11 - DisplayChar()
  2.    Micro Cornucopia Magazine Issue #46 */
  3.  
  4. /*-- Crudely display a character of a font --*/
  5.  
  6. void DisplayChar(unsigned char ch, char* bitmap, int Height,
  7.                  int BitMapWidth, int chofstable[])
  8.   {
  9.   printf("char: %02x, %d bits wide\n", ch, chofstable[ch+1]-chofstable[ch]);
  10.   int const bitoffset = (chofstable[ch] & 7);
  11.   bitmap += chofstable[ch] >> 3;   /* byte offset of start of char */
  12.  
  13.   for (int r = 0; r < Height; r++)
  14.     {
  15.     char* ptr = bitmap;
  16.     char workbyte = (*ptr++) << bitoffset;
  17.     int bcount = (7 - bitoffset);
  18.     for (int bitstoprint = chofstable[ch+1] - chofstable[ch];
  19.          bitstoprint > 0; bitstoprint--)
  20.       {
  21.       putchar(workbyte & 0x80 ? '*':'.');
  22.       workbyte <<= 1;
  23.       if (!bcount--)
  24.         {
  25.         workbyte = *ptr++;
  26.         bcount = 7;
  27.         }
  28.       } /* for b */
  29.     putchar('\n');
  30.     bitmap += BitMapWidth;
  31.     } /* for r */
  32.   } /* DisplayChar */
  33.  
  34. /*-------------------------------------------------------------------*/
  35. main( int argc, char* argv[ ] )
  36. { /* print all chars in Gem Font file given on command line */
  37.   ReadGemFont(argv[1]);
  38.   for (int ch = 0; ch <= GemFont.gfLastChar - GemFont.gfFirstChar; ch++)
  39.     DisplayChar(ch, bitmap, GemFont.gfFormHeight,
  40.                 GemFont.gfFormWidth, chofstable);
  41.   printf("Done.\n");
  42. }
  43.  
  44.